package com.guijq.design.practice.one;

import java.util.function.Consumer;

/**
 * @Author timyag
 * @Date 2021/4/15 10:24
 * @Version 1.0
 */
public class PoisonBox extends Box {

    public PoisonBox(int innderMoney) {
        super(innderMoney);
    }

    @Override
    protected <T extends Role> Consumer<Role> getRoleBehavior(Class<T> roleClass) {
        if (roleClass == Solider.class) {
            return (role) -> {
                role.hp = role.hp * 0.9;
                role.money += this.money * 1.2;
            };
        } else if (roleClass == Mage.class) {
            return role -> {
                role.hp = role.hp * 0.7;
                role.money += this.money * 1.4;
            };

        }
        return null;
    }

}
